home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / VISIMP.ZIP / MRUTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-09  |  4KB  |  140 lines

  1. program MRUTest;
  2. uses OWindows, WinTypes, WinProcs, OStdDlgs, OMRUList, WinDOS, Strings, SPopUp;
  3. {$R MRU.RES}
  4. const
  5.      CM_Quit = 108;
  6.      CM_Open = 102;
  7.  
  8. type
  9.     PWinApp = ^TWinApp;
  10.     TWinApp = object( TApplication )
  11.       procedure InitMainWindow; virtual;
  12.     end;
  13.  
  14.     PAppWin = ^TAppWin;
  15.     TAppWin = object( TWindow )
  16.       MRU : PMRUList;
  17.       APop : PSPopUp;
  18.       Buf : array[0..fsPathName] of Char;
  19.       IniFile : array[0..fsPathName] of Char;
  20.       KeyName : array[0..31] of Char;
  21.       constructor Init( AParent: PWindowsObject; ATitle: PChar );
  22.       destructor  Done; virtual;
  23.       procedure   Quit( var Msg: TMessage ); virtual CM_First + CM_Quit;
  24.       procedure   FileOp( var Msg: TMessage ); virtual CM_First + CM_Open;
  25.       procedure   CMFile1( var Msg: TMessage ); virtual CM_First + CM_File1;
  26.       procedure   CMFile2( var Msg: TMessage ); virtual CM_First + CM_File2;
  27.       procedure   CMFile3( var Msg: TMessage ); virtual CM_First + CM_File3;
  28.       procedure   CMFile4( var Msg: TMessage ); virtual CM_First + CM_File4;
  29.       procedure   CMFile5( var Msg: TMessage ); virtual CM_First + CM_File5;
  30.       procedure   PopDone( var Msg: TMessage ); virtual WM_First + WM_SPOPUP_DONE;
  31.       procedure   SetupWindow; virtual;
  32.     end;
  33.  
  34.     constructor TAppWin.Init;
  35.     begin
  36.          inherited Init( AParent, ATitle );
  37.          Attr.Menu := LoadMenu( HInstance, 'MRU1' );
  38.          MRU := new( PMRUList, Init(0,5,0));
  39.          StrCopy( Buf, '*.pas' );
  40.          StrCopy( IniFile, 'test.ini' );
  41.          StrCopy( KeyName, 'MyFiles' );
  42.     end;
  43.  
  44.     procedure TAppWin.SetupWindow;
  45.     begin
  46.          MRU^.LoadMRUList( Application^.MainWindow^.HWindow, IniFile, KeyName );
  47.     end;
  48.  
  49.     destructor TAppWin.Done;
  50.     begin
  51.          MRU^.SaveMRUList( IniFile, KeyName );
  52.          inherited Done;
  53.     end;
  54.  
  55.     procedure TAppWin.Quit;
  56.     begin
  57.          inherited CMExit( Msg );
  58.     end;
  59.  
  60.     procedure TAppWin.FileOp;
  61.     begin
  62.          if Application^.ExecDialog(New(PFileDialog,
  63.          Init(@Self, PChar(sd_FileOpen), Buf))) = id_OK then
  64.          begin
  65.          MRU^.AddMRUItem( HWindow, Buf );
  66.          end;
  67.     end;
  68.  
  69.     procedure TAppWin.PopDone;
  70.     begin
  71.          Dispose( APop, Done );
  72.     end;
  73.  
  74.     procedure TAppWin.CMFile1;
  75.     var
  76.        P : PChar;
  77.     begin
  78.          GetMem( P, 160 );
  79.          MRU^.GetMRUItem( Msg.wParam, P );
  80.          APop := PSPopUp(Application^.MakeWindow(new( PSPopUp, Init(@Self,10,10, P))));
  81.          MRU^.DeleteMRUItem( HWindow, P );
  82.          FreeMem( P, 160 );
  83.     end;
  84.  
  85.     procedure TAppWin.CMFile2;
  86.     var
  87.        P : PChar;
  88.     begin
  89.          GetMem( P, 160 );
  90.          MRU^.GetMRUItem( Msg.wParam, P );
  91.          APop := PSPopUp(Application^.MakeWindow(new( PSPopUp, Init(@Self,10,10, P))));
  92.          MRU^.DeleteMRUItem( HWindow, P );
  93.          FreeMem( P, 160 );
  94.     end;
  95.  
  96.     procedure TAppWin.CMFile3;
  97.     var
  98.        P : PChar;
  99.     begin
  100.          GetMem( P, 160 );
  101.          MRU^.GetMRUItem( Msg.wParam, P );
  102.          APop := PSPopUp(Application^.MakeWindow(new( PSPopUp, Init(@Self,10,10, P))));
  103.          MRU^.DeleteMRUItem( HWindow, P );
  104.          FreeMem( P, 160 );
  105.     end;
  106.  
  107.     procedure TAppWin.CMFile4;
  108.     var
  109.        P : PChar;
  110.     begin
  111.          GetMem( P, 160 );
  112.          MRU^.GetMRUItem( Msg.wParam, P );
  113.          APop := PSPopUp(Application^.MakeWindow(new( PSPopUp, Init(@Self,10,10, P))));
  114.          MRU^.DeleteMRUItem( HWindow, P );
  115.          FreeMem( P, 160 );
  116.     end;
  117.  
  118.     procedure TAppWin.CMFile5;
  119.     var
  120.        P : PChar;
  121.     begin
  122.          GetMem( P, 160 );
  123.          MRU^.GetMRUItem( Msg.wParam, P );
  124.          APop := PSPopUp(Application^.MakeWindow(new( PSPopUp, Init(@Self,10,10, P))));
  125.          MRU^.DeleteMRUItem( HWindow, P );
  126.          FreeMem( P, 160 );
  127.     end;
  128.  
  129.     procedure TWinApp.InitMainWindow;
  130.     begin
  131.          MainWindow := new( PAppWin, Init( nil, 'MRU Test' ) );
  132.     end;
  133.  
  134. var
  135.    WinApp : TWinApp;
  136. begin
  137.      WinApp.Init('WINAPP');
  138.      WinApp.Run;
  139.      WinApp.Done;
  140. end.